﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.ApplicationServices;
using System.Web.Mvc;
using WebApplication1.Core;

namespace WebApplication1.Controllers
{
    public class DefaultController : Controller
    {
        // GET: Default
        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated)
            {

            }
            return View();
        }public ActionResult Index2()
        {
            if (User.Identity.IsAuthenticated)
            {

            }
            return View();
        }
        [AllowAnonymous]
        public ActionResult Login()
        { 
            ViewBag.AccountName = User.Identity.Name;
            return View();
        }
        [HttpPost]
        [AllowAnonymous]
        public JsonResult Login(WebApplication1.Models.LoginModel model) {
            if (ModelState.IsValid)
            {
                var aus = new MyAuthenticationService();
                aus.SignIn("admin", "admin", true);

                return Json(new { success = true });
            }
            else
            {
                return Json(new { success = false,msg="您的输入不正确。"});
            }

        }
    }
}